Move notebook to /lib
[andmenj-acm.git] / lib / Mi manual de algoritmos / version_maraton_nacional_2008 / src / java / io_file.tex
blob12bef6040c0ce81047aaca01e99ba350d95df3bb
1 % Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
3 {\ttfamily \raggedright {
4 \noindent
5 \mbox{}\textbf{\textcolor{RoyalBlue}{import}}\ java\textcolor{BrickRed}{.}io\textcolor{BrickRed}{.*;} \\
6 \mbox{}\textbf{\textcolor{RoyalBlue}{import}}\ java\textcolor{BrickRed}{.}util\textcolor{BrickRed}{.*;} \\
7 \mbox{}\textbf{\textcolor{Blue}{public}}\ \textbf{\textcolor{Blue}{class}}\ BooleanTree\ \textcolor{Red}{\{} \\
8 \mbox{}\ \ \ \ \ \ \ \ \textbf{\textcolor{Blue}{public}}\ \textbf{\textcolor{Blue}{static}}\ \textcolor{ForestGreen}{void}\ \textbf{\textcolor{Black}{main}}\textcolor{BrickRed}{(}String\textcolor{BrickRed}{[]}\ args\textcolor{BrickRed}{)}\ \textbf{\textcolor{Blue}{throws}}\ FileNotFoundException\ \textcolor{Red}{\{} \\
9 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ System\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{setIn}}\textcolor{BrickRed}{(}\textbf{\textcolor{Blue}{new}}\ \textbf{\textcolor{Black}{FileInputStream}}\textcolor{BrickRed}{(}\texttt{\textcolor{Red}{"{}tree.in"{}}}\textcolor{BrickRed}{));} \\
10 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ System\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{setOut}}\textcolor{BrickRed}{(}\textbf{\textcolor{Blue}{new}}\ \textbf{\textcolor{Black}{PrintStream}}\textcolor{BrickRed}{(}\texttt{\textcolor{Red}{"{}tree.out"{}}}\textcolor{BrickRed}{));} \\
11 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Scanner\ reader\ \textcolor{BrickRed}{=}\ \textbf{\textcolor{Blue}{new}}\ \textbf{\textcolor{Black}{Scanner}}\textcolor{BrickRed}{(}System\textcolor{BrickRed}{.}in\textcolor{BrickRed}{);} \\
12 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ N\ \textcolor{BrickRed}{=}\ reader\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{nextInt}}\textcolor{BrickRed}{();} \\
13 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textbf{\textcolor{Blue}{for}}\ \textcolor{BrickRed}{(}\textcolor{ForestGreen}{int}\ c\ \textcolor{BrickRed}{=}\ \textcolor{Purple}{1}\textcolor{BrickRed}{;}\ c\ \textcolor{BrickRed}{$<$=}\ N\textcolor{BrickRed}{;}\ \textcolor{BrickRed}{++}c\textcolor{BrickRed}{)}\ \textcolor{Red}{\{} \\
14 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{ForestGreen}{int}\ res\ \textcolor{BrickRed}{=}\ \textcolor{Purple}{100}\textcolor{BrickRed}{;} \\
15 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textbf{\textcolor{Blue}{if}}\ \textcolor{BrickRed}{(}res\ \textcolor{BrickRed}{$<$}\ \textcolor{Purple}{1000}\textcolor{BrickRed}{)} \\
16 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ System\textcolor{BrickRed}{.}out\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{println}}\textcolor{BrickRed}{(}\texttt{\textcolor{Red}{"{}Case\ \#"{}}}\ \textcolor{BrickRed}{+}\ c\ \textcolor{BrickRed}{+}\ \texttt{\textcolor{Red}{"{}:\ "{}}}\ \textcolor{BrickRed}{+}\ res\textcolor{BrickRed}{);} \\
17 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textbf{\textcolor{Blue}{else}} \\
18 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ System\textcolor{BrickRed}{.}out\textcolor{BrickRed}{.}\textbf{\textcolor{Black}{println}}\textcolor{BrickRed}{(}\texttt{\textcolor{Red}{"{}Case\ \#"{}}}\ \textcolor{BrickRed}{+}\ c\ \textcolor{BrickRed}{+}\ \texttt{\textcolor{Red}{"{}:\ IMPOSSIBLE"{}}}\textcolor{BrickRed}{);} \\
19 \mbox{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{Red}{\}} \\
20 \mbox{}\ \ \ \ \ \ \ \ \textcolor{Red}{\}} \\
21 \mbox{}\textcolor{Red}{\}} \\
23 } \normalfont\normalsize